const http = require('http')
const https = require('https')
const { ipcMain, webContents } = require('electron')
const red = '\x1b[31m'
const axios = require('axios')
export default function () {
  // 打开url
  ipcMain.handle('open-url', async (event, url) => {
    console.log('uuuuuuuuuuuu', url)
    return new Promise((resolve, reject) => {
      try {
        axios
          .get(url)
          .then((response) => {
            console.log(response.data)
            resolve(response.data)
            webContents.send('callback', response.data)
          })
          .catch((error) => {
            console.error(error)
          })
      } catch (error) {
        reject(error)
      }
    })
  })
}
